﻿package 
{
    public class Enemy 
    {
		import flash.display.DisplayObject;
		import flash.display.MovieClip;
		var timesThrough:int = 0;    
		var origx:int = 0;    
		var origy:int = 0;    
		var origScaleX:Number = 0;    
		var origScaleY:Number = 0;    
		var myDisplayObject:DisplayObject;
		var myBolt:DisplayObject;
		public function meetYourDisplayObject(display:DisplayObject, bolt:DisplayObject)
		{
            myDisplayObject = display;
			myBolt = bolt;
			bolt.visible = false;
			origScaleX = this.myDisplayObject.scaleX;
			origScaleY = this.myDisplayObject.scaleY;
			origx = this.myDisplayObject.x;
			origy = this.myDisplayObject.y;
        }
		
		public function advance():Boolean
		{
			if (myBolt.visible)
			{
				myBolt.visible = false;
				myDisplayObject.visible = true;
				return true;
			}
			if (timesThrough <= 3 )
			{
				//this.myDisplayObject.y = 130;
				this.myDisplayObject.y += 35 * timesThrough;
				//this.myDisplayObject.y = origy + ( * timesThrough);//(50 / (6 - timesThrough));
				//this.myDisplayObject.x -=(this.myDisplayObject.width  / 24);
				this.myDisplayObject.scaleX *= 1.33;
				this.myDisplayObject.scaleY *= 1.33;
				
				timesThrough++;
			}
			else
				return false;
			return true;
				
		}
		public function reset()
		{
			
			var m:MovieClip  = this.myDisplayObject as MovieClip;
			for (var i = 0; i< 50; i++)
				m.nextFrame();
			m.play();
			this.myDisplayObject.scaleX = origScaleX;
			this.myDisplayObject.scaleY = origScaleY;
			this.myDisplayObject.x = origx;
			this.myDisplayObject.y = origy;
			timesThrough = 0;
			myDisplayObject.visible = false;
			myBolt.visible = true;
		}
    }
}